package com.itheima_11;

import java.text.Collator;
import java.util.Locale;

public class Employee implements Comparable<Employee>{
    private String name;
    private int age;
    private int salary;

    public Employee() {
    }

    public Employee(String name, int age, int salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }

    @Override
    public int compareTo(Employee o) {
        Collator instance = Collator.getInstance(Locale.CHINA);
        int result=this.salary-o.salary;
        result=result==0? this.age-o.age:result;
        result=result==0? this.name.compareTo(o.name):result ;
        if(result==0){
            result=1;
        }
        return -result;
    }
}
